<!-- #region setup -->
<script lang="ts" setup>
import {BytDialogLoading} from '@byt/components';
import { useMessage,useDialog } from 'naive-ui';

// 全局挂载
window.$message = useMessage();
window.$dialog = useDialog();

const handleClick = () => {
  BytDialogLoading({
    title: '提示',
    content: `确认是否发起退款？`,
    onConfirm: async () => {
      return await promiseFunc();
    }
  })
}

const promiseFunc = async()=>{
  console.log("promiseFunc开始")
  let res = await new Promise((resolve, reject) => {
    setTimeout(()=>{
      resolve("ok")
      console.log("api结束")
    },2000)
  })
  console.log("结果是什么",res)
  console.log("promiseFunc结束")
  // true或者undefined表示关闭，false表示不关闭
  return true;
}
</script>
<!-- #endregion setup -->

<!-- #region first -->
<n-dialog-config>
  <n-button type="primary" @click="handleClick">打开对话框</n-button>
</n-dialog-config>
<!-- #endregion first -->
